<?php

class ObjectArrayIterator {

	var $aElements;

	function ObjectArrayIterator() {
		$this->aElements = array();
	}

	function AddElement( $oElement ) {
		$this->aElements[] = $oElement;
	}
		
	function RewindElementIterator() {
		reset( $this->aElements );
	}
	
	function HasAnotherElement() {
		return current( $this->aElements ) !== false;	
	}
	
	function GetNextElement() {
		if ( $this->HasAnotherElement() ) {
			$oReturn = current( $this->aElements );
			next( $this->aElements );
			return $oReturn;
		}
		return false;
	}
	
	function HasSomeElements() {
		return count( $this->aElements ) > 0;	
	}
	
	function MergeElements( $oObjectArrayIterator ) {
		$oObjectArrayIterator->RewindElementIterator();
		while( $oObjectArrayIterator->HasAnotherElement() ) {
			$this->AddElement( $oObjectArrayIterator->GetNextElement() );
		}
	}
	
	function ReturnArrayFromCallback( $sFunction, $xParameter = null ) {

		$aReturnArray = array();
		$this->RewindElementIterator();
		while( $this->HasAnotherElement() ) {
			$oThisObjectElement = $this->GetNextElement();
			$aReturnArray[] = $oThisObjectElement->$sFunction( $xParameter );
		}
		return $aReturnArray;

	}
	
}

?>
